package com.hspedu.innerclass;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/1/28
 * @time 19:14
 */
public class MemberInnerClass {
    public static void main(String[] args) {
        Outer outer = new Outer();
        System.out.println(outer.n);

        Outer.InnerClass innerClass1 = outer.new InnerClass();

        Outer.InnerClass innerClass = outer.getInnerClass();
        innerClass.test();
        System.out.println(outer.n);

        Outer.InnerClass2 innerClass2 = new Outer.InnerClass2();
    }
}

class Outer{
    public int n = 1;
    private String name = "123";

    class InnerClass{
        public void test(){
            n = 2;
        }
    }

    static class InnerClass2{

    }

    public InnerClass getInnerClass(){
        InnerClass ic = new InnerClass();
        return ic;
    }
}